local skill = fk.CreateSkill {
  name = "counter_skill",
}

skill:addEffect("cardskill", {
  prompt = "#counter_skill",
  mod_target_filter = Util.TrueFunc,
  can_use = Util.CanUseToSelf,
  on_use = function (self, room, use)
    local player = use.from
    room:addSkill("#counter_trigger")
    if player then
      local cid = use.card:getEffectiveId()
      if not cid then return end
      local names = Fk:getAllCardNames("btd", true)
      if #names == 0 then return end
      local choice = room:askToChoice(player, {skill_name = self.name, choices = names, prompt = "#counter-record"})
      local tag = room:getTag("counter_record") or {}
      tag[tostring(cid)] = choice
      room:setTag("counter_record", tag)
    end
  end,
  about_to_effect = function (self, room, effect)
    -- 询问无懈之前，直接弃置此牌
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonPutIntoDiscardPile,
      skillName = self.name,
    }
    return true
  end,
  on_effect = function(self, room, effect)
    self:onNullified(room, effect)
  end,
  on_nullified = function(self, room, effect)
    room:moveCards{
      ids = room:getSubcardsByRule(effect.card, { Card.Processing }),
      toArea = Card.DiscardPile,
      moveReason = fk.ReasonUse,
    }
  end,
})

Fk:loadTranslationTable{
  ["counter_skill"] = "反制",
  ["#counter_skill"] = "反制：记录一个牌名，直到你下个判定阶段前，防止其他角色使用此牌",
  ["#counter-record"] = "反制：选择你要记录的牌名",
}
return skill
